package com.crs.controller.user;

import com.crs.dto.OwnerReplyDTO;
import com.crs.dto.UserFirstReviewDTO;
import com.crs.dto.UserReviewDTO;
import com.crs.result.Result;
import com.crs.service.ReviewService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/user/review")
public class ReviewController {

    @Autowired
    private ReviewService reviewService;

    @PostMapping("/userReview")
    public Result userReview(@RequestBody UserReviewDTO userReviewDTO){
        log.info("用户针对借阅记录进行评价");
        reviewService.userReview(userReviewDTO);
        return Result.success();
    }

    @PostMapping("/userFirstReview")
    public Result userReview(@RequestBody UserFirstReviewDTO userFirstReviewDTO){
        log.info("用户第一次对借阅记录进行评价");
        reviewService.userFirstReview(userFirstReviewDTO);
        return Result.success();
    }

    @PostMapping("/reply")
    public Result OwnerReply(@RequestBody OwnerReplyDTO ownerReplyDTO){
        log.info("资源拥有者回复");
        reviewService.reply(ownerReplyDTO);
        return Result.success();
    }

    @PutMapping("/updateLike")
    public Result updateLike(Long reviewId){
        log.info("更新点赞记录");
        reviewService.updateLike(reviewId);
        return Result.success();
    }
}
